var resume = new Vue({
    el: "#preview_resume",
    data() {
        return {
            services: services,
            userInfo:'',
            sexImg:null,
            age:null,
            workAge:null,
            careerObjective:'',
            experienceWork:null,
            experienceEducation:'',
            professionalSkill:null,
            experienceProject:null,
            resume:'',
            birthYear:'',
            firstWorkTime:'',
            telFlag:true,
            emailFlag:true,
            wechatFlag:true,
            websiteFlag:true
        }
    },
    created () {
        this.userInfo = LoginStatus();
        if(this.userInfo==false)
            return false;
        //判断性别，显示性别图标
        var sex = this.userInfo.gender;
        if(sex==1){
            this.sexImg = '../images/male.png';
        }else if(sex==2){
            this.sexImg = '../images/female.png';
        }else {
            this.sexImg = null;
        }
        //联系方式如果是空的就不显示
        if(!this.userInfo.tel){
            this.telFlag = false;
        }
        if(!this.userInfo.email){
            this.emailFlag = false;
        }
        if(!this.userInfo.wechat){
            this.wechatFlag = false;
        }
        if(!this.userInfo.webSite){
            this.websiteFlag = false;
        }



        //获取岁数，工作时间
        var thisYear =  parseInt(new Date().getFullYear());
        this.birthYear = parseInt(this.userInfo.birthday.substring(0,4));
        this.firstWorkTime = parseInt(this.userInfo.firstWorkTime.substring(0,4));
        this.age = thisYear-this.birthYear;
        this.workAge = thisYear-this.firstWorkTime;
        this.init();
    },
    methods:{
        init:function () {
            var that=this;
            $.ajax({
                url:that.services+"/user/resume"
                ,type:"get"
                ,async:false
                ,xhrFields: {
                    withCredentials: true
                }
                ,crossDomain: true
                ,success:function(res){
                    var check = ApiLoginStatus(res);
                    if(check==false)
                        return false;
                    that.careerObjective = res.data.careerObjective[0];
                    that.experienceWork = res.data.experienceWork;
                    that.experienceEducation = res.data.experienceEducation[0];
                    that.professionalSkill = res.data.professionalSkill;
                    that.experienceProject = res.data.experienceProject;
                    that.resume = res.data.resume;
                }
            });
        }
    }
});